<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<!DOCTYPE html>

<html lang="en">
<head>
<%@ include file="/common/common-css.jsp"%>
<link rel="stylesheet" type="text/css" href="${ctx}/css/wangEditor-1.3.11.css" />
<style>
   .load_bg{background:#000;opacity:0.1;left:0px;top:0px;position:fixed;height:100%;width:100%;overflow:hidden;z-index:10000;}
   .load_img{left:50%;top:180px;position:fixed;height:50px;overflow:hidden;z-index:20000;}
   .setnone{
	   display: none;
   }
   .widget-color-blue{
	   margin-top: 20px;
   }
   .autoTxtCount {
	   position: relative;
   }
   .autoTxtCount .tips {
	   position: absolute;
	   right: 5px;
	   bottom: 7px;
	   z-index: 99;
   }
   .wangEditor-container .wangEditor-textarea p{
	   margin: 0; 
   }
   .view{
	   border: 1px solid #cccccc;
   }
   .no-border{
	   border: none;
   }
   .img-box{
	  border: 1px solid #cccccc;
	  display: inline-block;
	  position: relative;
      padding: 20px 2px 2px 2px;	
      margin: 10px 5px 10px 5px;	  
   }
   .img-box img{
	  height: 180px;
   }
   .img-box i{
	  position: absolute;
	  top: 3px;
      right: 3px;
	  cursor: pointer;
      font-size: 1.2em;	  
   }
   .home_image-view{
	   max-width: 90%;
   }
   .mall-alert{
	  position: fixed;
	  z-index: 300000;
	  width: 50%;
	  left: 25%;
	  top: 30%;
	  display: none;
   }
   .modal{
	   top: 30%;
   }
   .checkbox label{
	   margin-left: 20px;
   }
   .checkbox label:nth-child(1){
	   margin-left: 0;
   }
   @media only screen and (min-width: 1280px){
	  .view{
		  margin-left: -16px;
	  }
   }
</style>
</head>
<body class="no-skin">
   <div  class="load_bg" style="display:none;" ></div>
   <img src="http://img.xmiles.cn/commentloading.gif" class="load_img" style="display:none"/>
   <div class="page-content">
       
	   <!--
	   <ul class="nav nav-pills nav-mall" role="tablist">
		  <li role="presentation" class="active"><a>新增商品</a></li>
		  <li role="presentation"><a href="">商品管理</a></li>
	   </ul>
	   <hr/>
	   -->
   
       <div class="page-content-area">
	       <div class="row">
			   <div class="col-xs-12 col-sm-12 widget-container-col">
					<div class="widget-box widget-color-blue">
					   <div class="widget-body">
							<div class="widget-main">
								<form name="mallProduct" method="post" enctype="multipart/form-data" action="">
									  <div class="row">
									  
										 <div class="form-group col-sm-1 col-xs-3 text-right">
											<label class="control-label"  for="recommend">手机号码以","隔开:</label>
										 </div>
										 <div class="form-group col-sm-11 col-xs-12 text-right" style="padding-left:12px;">
											<div class="input-group col-sm-12 col-xs-12 text-left">
												<textarea name="mobileNum" id='mobileNum' style='border:1px solid #cccccc; height: 150px; max-height: 300px; width: 100%;'>
												</textarea>
											</div>
										 </div>									 
									  </div>
									  
									  <div class="row">
									       <div class="form-group col-sm-1 col-xs-3 text-right">
											<label class="control-label"  for="recommend">发送内容</label>
										 </div>
										 <div class="form-group col-sm-11 col-xs-12 text-right" style="padding-left:12px;">
											<div class="input-group col-sm-12 col-xs-12 text-left">
												<input class="form-control" name="content" id='content' type="text" placeholder="请输入发送内容" />
											</div>
										 </div>	
									  </div>
									  <div class="row">
										  <div class="form-group col-sm-1 col-xs-3 text-right">
											<label class="control-label"  for="recommend">备注</label>
										 </div>
										 <div class="form-group col-sm-11 col-xs-12 text-right" style="padding-left:12px;">
											<div class="input-group col-sm-12 col-xs-12 text-left">
												<input class="form-control" name="memo" id='memo' type="text" placeholder="请输入备注" />
											</div>
										 </div>	
									  </div>	
									  <div class="row">
										 <div class="form-group col-sm-1 col-xs-3 text-right">
											<label class="control-label"  for="recommend">提示邮箱</label>
										 </div>
										 <div class="form-group col-sm-11 col-xs-12 text-right" style="padding-left:12px;">
											<div class="input-group col-sm-12 col-xs-12 text-left">
												<input class="form-control" name="email" id='email' type="email" placeholder="请输入提示邮箱" />
											</div>
										 </div>
									  </div>
									 
									<div class="form-group col-xs-12 col-sm-4 col-md-3 col-lg-3">
											<label class="col-sm-4 control-label"  style="text-align:right"  for="isprize">产品:</label>
											<div class="col-sm-8" style="padding-left:0;">
												<select class="form-control" name="pid" id="pid">
													<option value="">--产品--</option>
													<option value="8000">菠萝贷主包</option>
													<option value="8001">极速借钱</option>
													<option value="8002">菠萝贷iOS</option>
												</select>
											</div>
										</div>
									
								
									  <div class="row">  
										  <div class="col-md-12 center">
										        <button type="button" class="btn btn-lg btn-default no-border" id="zl" style="margin-right:20px;">
													<i class="ace-icon fa fa-floppy-o"></i> 整理格式
												</button>
												<button type="button" class="btn btn-lg btn-success no-border" id="save" >
													<i class="ace-icon fa fa-floppy-o"></i> 确认
												</button>
										  </div>
									  </div>
								</form>
							</div>
						</div>	
					</div>
				</div>	
             </div>				
		</div>
   </div>	
   
<!--模态框-->
<div class="modal fade" id="Modal">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title"></h4>
      </div>
      <div class="modal-body clearfix">
	    <form id="addImage" method="post" enctype="multipart/form-data" >
			<div class="row">
				<div class="form-group col-xs-12">
					<div class="input-group col-sm-12">
						<input type="file" class="form-control" name="myFile" accept=".png,.jpg,.jpeg" />
					</div>
				</div>
			</div>		
        </form>			
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
	    <button type="button" class="btn btn-primary" disabled id="confirm">上传</button>
      </div>
    </div><!-- /.modal-content -->
  </div><!-- /.modal-dialog -->
</div><!-- /.modal -->

<!--警告-->
<div class="alert alert-danger alert-dismissible mall-alert" role="alert">
  <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
  <b>注意:</b> &nbsp; <span id="alert-text"></span>
</div>


</body>
<%@ include file="/common/common-js.jsp" %>
<script type="text/javascript" src="${ctx}/ace/js/maxlength.js"></script>
<script type="text/javascript" src="${ctx}/js/wangEditor-1.3.11.min.js"></script>
<script type="text/javascript" src="${ctx}/js/jquery.form.js"></script>
<script type="text/javascript">
//$multiple为1--多选,$multiple为0--单选
var $multiple = 1;
var $selector = '';
var $input = '';
//首次添加时兑换码的类型,1为编辑时的code,2为编辑时的txt,3为新增
var firstAddHad = 3;

//声明一个期数的全局变量
var $periodIdObject = {};

//operator--1为更新,2为增加(以prd_id判断)
var operator = 1;
var prd_id = getQueryString('prd_id');
if(prd_id == '' || prd_id == null){
	operator = 2;
};

function toast(text, selector){
    $('#alert-text').text(text);
    $('.discovery-alert').show();
    if(selector != '' && selector != null){
        $(selector).focus();
    };
    setTimeout(function(){
        $('.discovery-alert').hide();
    },3000);
};

jQuery(function($) {
	
	//初始化编辑器
/* 	var editorPrddetail = $('#mobileNum').wangEditor({
		'menuConfig': [
		   []
		]
	}); */

	//var message=${message};
	//alert(message);
	

	
	//确认保存按钮
	$('#save').on('click', function(){
		if($('#mobileNum').val() == '' || $('#mobileNum').val() == null){
			toast('请填写手机号码', '#mobileNum');
			return false;
		}
		if($('#content').val() == '' || $('#content').val() == null){
			toast('请填写发送内容', '#content');
			return false;
		}
		if($('#memo').val() == '' || $('#memo').val() == null){
			toast('请填写备注', '#memo');
			return false;
		}
		if($('#email').val() == '' || $('#email').val() == null){
			toast('请填写邮箱', '#email');
			return false;
		}
		$(this).attr('disabled',false);
		saveForm();
	});
	
	$('#zl').on('click', function(){
		var mobileNum=$('#mobileNum').val().replace(/\ +/g,"").replace(/[\r\n]/g,",");
		$('#mobileNum').val(mobileNum);
	});
	
});

//表单异步提交
function saveForm(){
	var saveUrl=ctx + '/message/sendMessage.action';
 	//$('form[name="mallProduct"]').attr('action',saveUrl);
	var options = { 
			url :saveUrl,
			type : "POST",
			dataType : "json",
			beforeSend: function(){
				$(".load_bg,.load_img").show();
			},
			success : function(data) {
				var status=data.status;
				var message=data.message;
				if(status=="0"){
					message=message+"，以上号码格式不对";
					alert(message);
				}else{
					alert(message);
				}
			    
			},
			error: function(XMLHttpRequest, textStatus, errorThrown){
			    alert(textStatus);
			    console.log(XMLHttpRequest, textStatus, errorThrown);
			},
	        complete : function(){
				$(".load_bg,.load_img").hide();
			}
		};
    $('form[name="mallProduct"]').ajaxSubmit(options);
    
    //form.submit();
};





//接受URL参数，进行文档写入
function getQueryString(name) {
	var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
	var r = window.location.search.substr(1).match(reg);
	if (r != null) return decodeURI(r[2]); return null;
}

</script>
</html>